#!/usr/bin/env python

import robot_upstart
import os

j = robot_upstart.Job(name="ros", interface=os.environ.get('ROBOT_NETWORK'), workspace_setup=os.environ.get('ROBOT_SETUP'))

# Stuff to launch on system startup.
j.add(package="husky_base", glob="launch/*")

if os.path.exists('/dev/clearpath/imu') or os.path.exists('/dev/clearpath/um6'):
  j.add(package="husky_bringup", glob="launch/um6_config/*")

if os.path.exists('/dev/clearpath/um7'):
  j.add(package="husky_bringup", glob="launch/um7_config/*")

if os.path.exists('/dev/microstrain_gx3'):
  j.add(package="husky_bringup", glob="launch/microstrain_gx3_config/*")

if os.path.exists('/dev/microstrain_gx5'):
  j.add(package="husky_bringup", glob="launch/microstrain_gx5_config/*")

if os.path.exists('/dev/clearpath/gps'):
  j.add(package="husky_bringup", glob="launch/navsat_config/*")

if os.environ.get('HUSKY_LMS1XX_IP') or os.environ.get('HUSKY_LMS1XX_SECONDARY_IP'):
  j.add(package="husky_bringup", glob="launch/lms1xx_config/*")

if os.environ.get('HUSKY_LASER_3D_ENABLED'):
  j.add(package="husky_bringup", glob="launch/velodyne_config/*")

j.install()
